<script>
    let str = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

    let cites = [
        { py: 'beijing', name: '北京' },
        { py: 'alishan', name: '阿里山' },
        { py: 'beidaihe', name: '北戴河' },
        { py: 'shijiazhuang', name: '石家庄' },
        { py: 'henan', name: '河南' },
        { py: 'chongqing', name: '重庆' },
    ]


    let c = {};
     //for循环把上边的英文首字母添加到c的空对象里边去
    for(var i=0;i<str.length;i++){
        c[str[i]]=[];
    };
       //forEach循环找到cites里边的py项的下标0给转换到大写，转换成大写以后把每项的添加到对应的c对象里边去
    cites.forEach(function(item){
      tt= item.py[0].toUpperCase();
        c[tt].push(item)
        
        
    });
    console.log(c);
</script>